/**
 * Project: topdt-jbpm
 * Copyright 2013  Top Digital Technology  Co. Ltd.
 * All right reserved.
 */
package com.topdt.jbpm.form;

import com.alibaba.fastjson.JSON;
import com.topdt.jbpm.model.Application;
/**
 * 建立日期 : 2013-5-29 下午6:54:38<br>
 * 作者 : balance<br>
 * 模块 : 表单<br>
 * 描述 : 表单操作功能项目定义<br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
public class FormMenuDefin {
	private static final String[][] commonMenuItems = new String[][] { { "save", "保存" }, { "complete", "提交" },
			{ "delete", "删除" },  { "opinion", "意见" }, { "attach", "附件" },{"back","退回"},{"archives","归档"},{"publish","发布"}};

	private static final String[][] docMenuItems= new String[][] { { "edit", "编辑正文" }, { "signature", "签章" },
		{ "insert", "套用模板" }};
	/*
	 * wangxufeng edit 2014-11-11 10:32
	 */
	private static final String[][] remindMenuItems=new String[][]{{"next","下一步骤"},{"start","发起人"},{"all","全部经办人"}};
	private static final String[][] optionMenuItems = new String[][]{{"isAutoAddOption","是否自动增加意见"},{"defaultOption","默认意见"}};
	/*private static final String[][] menuItems = new String[][] { { "save", "保存" }, { "complete", "提交" },
		{ "delete", "删除" }, { "flow", "流程图" }, { "opinion", "意见" }, { "attach", "附件" }, { "supDo", "督办" },
		{ "pressDo", "催办" }, { "reload", "刷新" } };*/
	public static String[][] getMenuItems(String appAttr) {
		String[][] menus = new String[15][2];
		int j = 0;
		//普通表单
		if(Application.APPATTR_FORM.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				if(!strs[1].equals("发布")) {
					menus[j] = strs;
					j++;
				}
			}
		//普通公文
		} else if(Application.APPATTR_DOC.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				menus[j] = strs;
				j++;
			}
			//公文按钮
			for(int i=0; i<docMenuItems.length; i++) {
				String[] strs = docMenuItems[i];
				menus[j] = strs;
				j++;
			}
		//外置表单
		} else if(Application.APPATTR_CUSTOM_FORM.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				if(!strs[1].equals("发布")) {
					menus[j] = strs;
					j++;
				}
			}
		//外置公文
		} else if(Application.APPATTR_CUSTOM_DOC.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				menus[j] = strs;
				j++;
			}
			//公文按钮
			for(int i=0; i<docMenuItems.length; i++) {
				String[] strs = docMenuItems[i];
				menus[j] = strs;
				j++;
			}
		//外置表单和意见
		} else if(Application.APPATTR_CUSTOM_FORM_OPINION.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				if(!strs[1].equals("发布") || !strs[1].equals("意见")) {
					menus[j] = strs;
					j++;
				}
			}
		//外置公文和意见
		} else if(Application.APPATTR_CUSTOM_DOC_OPINION.equals(appAttr)) {
			for(int i=0; i<commonMenuItems.length; i++) {
				String[] strs = commonMenuItems[i];
				if(!strs[1].equals("意见")) {
					menus[j] = strs;
					j++;
				}
			}
			//公文按钮
			for(int i=0; i<docMenuItems.length; i++) {
				String[] strs = docMenuItems[i];
				menus[j] = strs;
				j++;
			}
		}

		String[][] result = new String[j][2];
		System.arraycopy(menus, 0, result, 0, j);
		return result;

	}

	public static void main(String[] args) {
		System.out.print(JSON.toJSON(commonMenuItems));
	}
	/**
	 *
	 * <b>Method getRemindmenuitems</b>
	 * <dd>方法作用：(得到通知的对象)
	 * @return
	 * @since Met 1.0
	 */
	public static String[][] getRemindmenuitems() {
		return remindMenuItems;
	}
	/**
	 *
	 * <b>Method getOptionMenuItems</b>
	 * <dd>方法作用：(得到意见菜单项)
	 * @return
	 * @since Met 1.0
	 */
	public static String[][] getOptionMenuItems() {
		return optionMenuItems;
	}
}
